import 'package:flutter/cupertino.dart';
import 'package:lib_uikit/theme/gt_colors_v3.dart';

class GTHorizontalStepsV3 extends StatelessWidget {
  const GTHorizontalStepsV3({super.key, required this.nodeTexts, required this.currentIndex});

  /// 标题
  final List<String> nodeTexts;

  /// 当前下标
  final int currentIndex;

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 20,
      child: Stack(
        alignment: Alignment.center,
        children: [
          Positioned(left: 2, right: 2, child: _buildLine()),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: nodeTexts.map((e) => _buildItem(e)).toList(),
          ),
        ],
      ),
    );
  }

  Widget _buildItem(String text) {
    int index = nodeTexts.indexOf(text);
    return Container(
      alignment: Alignment.center,
      padding: const EdgeInsets.only(left: 8, right: 8),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(20),
        color: GTColorsV3.uikitNeutral3V3.color,
      ),
      child: Text(
        text,
        style: TextStyle(
          color: index <= currentIndex ? GTColorsV3.text1.color : GTColorsV3.text3.color,
          fontWeight: FontWeight.w500,
          fontFamily: 'GTFontFamily',
          fontSize: 10,
        ),
      ),
    );
  }

  Widget _buildLine() {
    return Container(height: 2, color: GTColorsV3.divider5.color);
  }
}
